<?php

?>

<meta http-equiv="Content-type" content="text/html;charset=UTF-8">
<html>
<head>
<title>ABC AND YOU</title>

<script src="/socket.io/socket.io.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>
<script src="http://192.168.2.234/mootools/mootools-core-1.4.5-full-compat.js"></script>
<script src="http://192.168.2.234/breslin/clientside/application/application_breslin.php"></script>
<script src="http://192.168.2.234/breslin/clientside/network/network.php"></script>
<script src="http://192.168.2.234/breslin/breslin/statemachine/state.php"></script>
<script src="http://192.168.2.234/breslin/statemachine/state_machine.php"></script>
<script src="http://192.168.2.234/breslin/clientside/application/states/application_global.php"></script>
<script src="http://192.168.2.234/breslin/clientside/application/states/application_initialize.php"></script>
<script src="http://192.168.2.234/breslin/clientside/application/states/application_main.php"></script>
<script src="http://192.168.2.234/breslin/clientside/application/states/application_play.php"></script>
<script src="http://192.168.2.234/breslin/clientside/bytebuffer/byte_buffer.php"></script>
<script src="http://192.168.2.234/breslin/clientside/game/game.php"></script>
<script src="http://192.168.2.234/breslin/clientside/game/states/game_global.php"></script>
<script src="http://192.168.2.234/breslin/clientside/game/states/game_initialize.php"></script>
<script src="http://192.168.2.234/breslin/clientside/game/states/game_pause.php"></script>
<script src="http://192.168.2.234/breslin/clientside/game/states/game_play.php"></script>
<script src="http://192.168.2.234/breslin/clientside/shape/shape.php"></script>
<script src="http://192.168.2.234/breslin/math/vector_3d.php"></script>
<script src="http://192.168.2.234/breslin/clientside/command/command.php"></script>
<script src="http://192.168.2.234/breslin/clientside/div/div.php"></script>
<script src="http://192.168.2.234/breslin/clientside/ability/ability.php"></script>
<script src="http://192.168.2.234/breslin/clientside/ability/move/ability_move.php"></script>
<script src="http://192.168.2.234/breslin/clientside/ability/move/ability_move_state.php"></script>
<script src="http://192.168.2.234/breslin/clientside/ability/move/global_process_tick_move.php"></script>
<script src="http://192.168.2.234/breslin/clientside/ability/move/catchup_process_tick_move.php"></script>
<script src="http://192.168.2.234/breslin/clientside/ability/move/normal_process_tick_move.php"></script>
<script src="http://192.168.2.234/breslin/clientside/ability/move/normal_interpolate_tick_move.php"></script>
<script src="http://192.168.2.234/breslin/clientside/ability/move/ability_move_state_machine.php"></script>
<script src="http://192.168.2.234/breslin/clientside/animation/animation.php"></script>
<script src="http://192.168.2.234/breslin/clientside/animation/animation_advanced.php"></script>

</head>

<body bgcolor="grey">

<script>

var mApplication;
var mSize = 0;
var mMiddleOfViewPort = new Vector3D();;

window.addEvent('domready', function()
{
       	mSize = window.getSize();

        //let's move control object to middle of screen
        mMiddleOfViewPort.x =  mSize.x / 2;
        mMiddleOfViewPort.y =  0;
        mMiddleOfViewPort.z =  mSize.y / 2;

        mApplication = new ApplicationBreslin('192.168.2.234','10000');
       	
        //input
        document.addEvent("keydown", mApplication.keyDown);
        document.addEvent("keyup", mApplication.keyUp);

        //main loop
	mIntervalCount = 0;
        mInterval=setInterval("mApplication.processUpdate()",32)
        
	mApplication.mNetwork.mSocket.on('news', function (data)
        {
                s = data.split(',');

                byteBuffer = new ByteBuffer(s);

                type = byteBuffer.readByte();

                if (type == -103)
                {
			mApplication.mGame.addShape(byteBuffer);
                }

                if (type == 1)
                {
			mIntervalCount++;
		
			//check if we stopped game loop	
			if (mIntervalCount > 25)
			{
				//game loop stopped so let's clear interval and start a new one.	

				//clear it
				clearInterval(mInterval);

				//set it again
        			mInterval=setInterval("mApplication.processUpdate()",32)

				mIntervalCount = 0;

			}
				
                        mApplication.mGame.readServerTick(byteBuffer);
                }
        });
}
);

window.onresize = function(event)
{
	mSize = window.getSize();	

        //let's move control object to middle of screen
        mMiddleOfViewPort.x =  mSize.x / 2;
        mMiddleOfViewPort.y =  0;
        mMiddleOfViewPort.z =  mSize.y / 2;
}


</script>

</body>
</html>
